﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TanWeb.Helpers;
using System.IO;

namespace TanWeb.Models.Entities
{
    public class ProductProfile
    {
        public int id { set; get; }

        public int GroupId { set; get; }

        public int SubGroupId { set; get; }

        public string Name { set; get; }

        public decimal Price { set; get; }

        public string Description { set; get; }

        public string ImageName { set; get; }

        public string GetTempImagePath(string type = null)
        {
            if (ImageName == null || ImageName == string.Empty) 
            {
                return string.Empty;
            }
            string path = Constants.PATH_UPLOAD_IMAGE.Replace("..", "") + "/" + ImageName;
            string imagePath = System.Web.Hosting.HostingEnvironment.MapPath(path);
            type = type == null ? Constants.TYPE_IMAGE_MINIMUM : type;
            System.Drawing.Image image = Utils.GetResizedImage(imagePath, type);
            return Utils.GetImageUrl(image);
        }
    }
}